package common

import "strings"

// IsStaticStr 判断是被引号包裹的字符串
func IsStaticStr(s string) bool {
	return strings.Index(s, "\"") == 0 && strings.LastIndex(s, "\"") == len(s)-1
}

// ToStaticStr 字符串去引号
func ToStaticStr(s string) string {
	return s[1 : len(s)-1]
}

// TryIntoStaticStr 对被引号包裹的字符串去引号
func TryIntoStaticStr(s interface{}) interface{} {
	if v, ok := s.(string); ok {
		if IsStaticStr(v) {
			return ToStaticStr(v)
		}

		return v
	}

	return s
}
